﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WMSTest
{
    class ImageTile
    {
        private string _name; 
        private int _width;
        private int _height; 
        private string _fileFormat;
        private byte[] _imageData;

        public ImageTile()
        {
            _imageData = new byte[0];
        }

        public ImageTile(int width, int height, string fileFormat, byte[] imageData)
        {
            this._width = width;
            this._height = height;
            this._fileFormat = fileFormat;
           
            this._imageData = new byte[imageData.Length];
            Array.Copy(imageData, this._imageData, imageData.Length);
        }

        public void WriteToFile(string filePath, string fileName, string fileExt)
        {
            filePath += fileName;
            filePath += "." + fileExt;

            FileStream fout = new FileStream(filePath, FileMode.OpenOrCreate);

            BinaryWriter writer = new BinaryWriter(fout);
            writer.Write(_imageData);
            writer.Close();
        }

        #region Properties
        
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        public int Width
        {
            get
            {
                return _width;
            }
            set
            {
                _width = value;
            }
        }

        public int Height
        {
            get
            {
                return _height;
            }
            set
            {
                _height = value;
            }
        }

        public string FileFormat
        {
            get
            {
                return _fileFormat;
            }
            set
            {
                _fileFormat = value;
            }
        }


        #endregion


    }
}
